fix(sdks/ts): don't crash on Node watch-mode messages - #4284
Conversation
|
@princed is attempting to deploy a commit to the Hatchet Team on Vercel. A member of the Team first needs to authorize it. |
gregfurman
left a comment
There was a problem hiding this comment.
Thanks for the neat fix! I'd love a small reproducer so I can compare this new behaviour locally. Feel free to even provide this output yourself within the PR body.
Also, could you include an entry for this in the sdks/typescript/CHANGELOG.md?
Once done, think this looks good to go 馃槃
|
馃憢 @princed. Are you still able to provide a reproducer? |
|
Sorry @gregfurman, I haven't had time to prepare a full-fledged repro it a repo/gist, but actually you can follow these steps:
Please let me know if you need more details. If you would like a working repro, can you point me at any example that be easily run? |
|
Hey @gregfurman, I've just had a look, it seems to be a simple repro: Steps
env TS_NODE_TRANSPILE_ONLY=true node --watch \
-r ts-node/register \
-r tsconfig-paths/register \
src/v1/examples/quickstart/worker.ts
I've also updated the changelog as requested. |
gregfurman
left a comment
There was a problem hiding this comment.
LGTM! Was able to reproduce this with Node v24.18.0. Thanks for the neat contribution!
|
Awesome, thanks for merging! |
Description
Fixes a Node watch-mode compatibility issue in the TypeScript SDK heartbeat worker. Newer Node worker reload/watch behaviour can emit internal worker-thread messages such as
watch:requireandwatch:importthrough the normalmessageevent, see nodejs/node#62368.The heartbeat controller previously assumed every worker message was a heartbeat log message and dynamically dispatched
this.logger[message.type](message.message), which can fail for those internal messages.For internal I used a much simpler fix via
yarn patch, please let me know if that's something you prefer instead, happy to update the PR.Similar problem was also encounter in other projects, e.g. https://redirect.github.com/pinojs/thread-stream/pull/213
Type of change
What's Changed
Checklist
Changes have been:
Testing
yarn linkin an affected project.馃 AI Disclosure